﻿{include file="public/header" /}
<form method="post" class="padding">
    <div class="panel admin-panel">
        <div class="panel-head"><strong>{:lang('currency')['edit']}{:lang('label')['category']}</strong></div>
        <div class="padding border-bottom">
            <a type="button" class="button button border-green addcat" href="#"/>{:lang('currency')['add']}{:lang('label')['category']}</a>
            <script>
                //city 参数和回调
                var pid="{:input('get.pid')}";
                var cid="{:input('get.cid')}";
                var aid="{:input('get.aid')}";
                var selectc = true;
                var selecta = true;
                function select_p(){
                    return false;
                }
                function select_c(){
                    return false;
                }
                function select_a(){
                    location.href="?pid="+pid+"&cid="+cid+"&aid="+aid;
                }
            </script>
            {:lang('label')['select']}{:lang('currency')['city']}:{include file="public/city" /}
        </div>
        <table class="table table-hover">
            <tr>
                <th width="100">{:lang('label')['image']}</th>
                <th width="100">{:lang('label')['title']}</th>
                <th width="100">{:lang('label')['handle']}</th>
            </tr>
            {volist name="data" id="volist"}
            <tr>
                <td style="line-height:40px"><input readonly id="scimage{$volist.title}" data-id="{$volist.id}" type="text" class="hidden">
                <img data-id="scimage{$volist.title}" style="width: 40px;height: 40px" src="{$volist.image}"/></td>
                <td style="line-height:40px"><strong>{$volist.title}</strong></td>
                <td style="line-height:40px"><a class="button border-blue button-little editcat" data-id="{$volist.id}">{:lang('currency')['edit']}</a>
                    <a class="button border-yellow button-little delcat" data-id="{$volist.id}">{:lang('currency')['del']}</a>
                </td>
            </tr>
            {/volist}
        </table>
    </div>
</form>
<script>
    layer.config({
        extend: 'extend/layer.ext.js'
    });
    $('.flagcat').click(function () {
        var mythis = $(this)
        var str = mythis.attr('data-id');
        var id = str.split("&")[0];
        var flag = str.split("&")[1];
//                $.getJSON("__URL__/category_flag.html?id="+id+"&flag="+flag,function(data){
//                    if(data.code == 'success'){
//                        msg(data.msg,1);
//                        location.reload();
//                    }
//                });
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['350px', '260px'], //宽高
            content: '__URL__/flag_edit.html?id=' + id
        });
    })
    $('.delcat').click(function () {
        var mythis = $(this)
        var id = mythis.attr('data-id');
        layer.confirm("确定要删除吗？（请确保此分类下无商家，否则可能会导致数据异常！）", {
            btn: ["{:lang('currency')['status_1']}", "{:lang('currency')['status_2']}"] //按钮
        }, function () {
            $.getJSON("__URL__/category_del.html?id=" + id, function (data) {
                if (data.code == 'success') {
                    msg(data.msg, 1);
                    location.reload();
                }
            });
        });
    });
    $('.addcat').click(function () {
        layer.open({
            type: 2,
            title: '',
//					shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['400px', '330px'], //宽高
            content: '__URL__/category_edit.html'
        });
    });
    $('.addcatsub').click(function () {
        var mythis = $(this)
        var gid = mythis.attr('data-id');
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['350px', '260px'], //宽高
            content: '__URL__/category_edit.html?gid=' + gid
        });
    });
    $('.editcat').click(function () {
        var mythis = $(this)
        var id = mythis.attr('data-id');
//				layer.prompt({title:'{:lang('currency')['edit']}{:lang('label')['category']}'},function(val){
//					$.post("__ROOT__/admin/service/category_edit.html?id="+id,{title:val},function(data){
//						if(data.code == 'success'){
//							msg(data.msg,1);
//							location.reload();
//						}
//					});
//				});
        layer.open({
            type: 2,
            title: '',
//                    shade:false,
//                    skin: 'layui-layer-rim', //加上边框
            area: ['400px', '330px'], //宽高
            content: '__URL__/category_edit.html?id=' + id
        });
    });
    function uploadfunc(id) {
        var url = $("#" + id).val();
        var dataid = $("#" + id).attr('data-id');
        $("#" + id).parent().find('img').attr('src', url);
        $.post("__URL__/category_edit.html?id=" + dataid, {image: url}, function (data) {
            if (data.code == 'success') {
                msg(data.msg, 1);
            }
        });
    }
</script>
{include file="public/footer" /}